//用于数据缓存

let dataCache = {
    
 

}

const install = function (Vue) {

    Vue.prototype.$cache = {
        set: function (firKey, value) {
            dataCache[firKey] = value
        },
        get: function (firKey) {
            if (!dataCache[firKey]) {
                return null
            }
            return dataCache[firKey]
        },
        has: function (firKey) {
            return !!dataCache[firKey]
        },
        clear: function (firKey, secKey) {
            if (firKey) {
                if (secKey) {
                    delete dataCache[firKey][secKey]
                } else {
                    delete dataCache[firKey]
                }
            } else {
                dataCache = {}
            }
        },
        //用于缓存双重key
        set2: function (firKey, secKey, value) {
            if (!dataCache[firKey]) {
                dataCache[firKey] = {}
            }
            dataCache[firKey][secKey] = value
        },
        get2: function (firKey, secKey) {
            if (!dataCache[firKey]) {
                return null
            }
            if (!dataCache[firKey][secKey]) {
                return null
            }
            return dataCache[firKey][secKey]
        },
        has2: function (firKey, secKey) {
            return !!dataCache[firKey] && !!dataCache[firKey][secKey]
        },
    }
}

export default {
    install
}